package com.generate.tools.utils;

import java.util.Arrays;
import java.util.List;

public class StringUtils {
	public static String getColumnName(String column){
		if(column == null){
			return "";
		}
		if(column.indexOf("_") <= 0){
			return column;
		}
		
		List<String> list =Arrays.asList(column.split("_"));
		StringBuilder sb = new StringBuilder(list.get(0));
		for(int i=1;i<list.size();i++){
			sb.append(upperCase(list.get(i)));
		}
		
		return String.valueOf(sb);
	}
	
	public static String lowerCase(String str) {
		if (str == null || str == "") {
			return str;
		}
		char[] ch = str.toCharArray();
		if (ch[0] >= 'A' && ch[0] <= 'Z') {
			ch[0] = (char) (ch[0] + 32);
		}

		return new String(ch);
	}
	
	/**
	 * 功能：将输入字符串的首字母改成大写
	 * 
	 * @param str
	 * @return
	 */
	public static String upperCase(String str) {
		if (str == null || str == "") {
			return str;
		}
		char[] ch = str.toCharArray();
		if (ch[0] >= 'a' && ch[0] <= 'z') {
			ch[0] = (char) (ch[0] - 32);
		}

		return new String(ch);
	}
	public static void main(String[] args) {
		System.out.println(getColumnName("fund_Id"));
	}
}
